SUBROUTINE binom(f,n)
! Binomial probability mass function with p=1/2
	IMPLICIT NONE
    INTEGER, INTENT(IN)  ::  n
	DOUBLE PRECISION, DIMENSION(:), INTENT(OUT) :: f(n)
	INTEGER :: k
	f(1)=2.0D0**(1-n)
	DO k=1,n-1
		f(k+1)=f(k)*(n-k)/k
	END DO
END SUBROUTINE binom